home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / fifth21 / bld2.fiv < prev    next >
Text File  |  1986-08-10  |  43KB  |  1,928 lines

  1. CREATE BUILD
  2. CREATE |
  3. CREATE FILENAME
  4. EDIT
  5. create filename 80 allot
  6. ~UP
  7. CREATE HN
  8. EDIT
  9. \ handle for the Helpfile New...
  10. variable hn
  11. ~UP
  12. CREATE HT
  13. EDIT
  14. \ Handle for Helpfile Temporary.
  15. variable ht
  16. ~UP
  17. CREATE TABLE.LENGTH
  18. EDIT
  19. \ Variable holding the table length.
  20. variable table.length
  21. ~UP
  22. CREATE LEN
  23. EDIT
  24. \ Used to keep track of offsets into the definitions.
  25. variable len
  26. ~UP
  27. CREATE OPENFILES
  28. CREATE NEWFILE
  29. EDIT
  30. \ ( filename -> handle )
  31. \ Aborts the program if can not open file.
  32. : newfile
  33.   dup delete if else drop endif \ Delete old file.
  34.   32 createfile if else         \ Create file. If an error then:
  35.     0 24 gotoxy                 \    Goto bottom of screen.
  36.     ." Cannot create file!"     \    Error message
  37.     abort                       \    End program.
  38.   endif
  39. ;
  40. ~UP
  41. EDIT
  42. \ Open the files.
  43. : openfiles
  44.    cls 10 10 gotoxy
  45.   ." I need a simple file name. No extention, please!"
  46.   10 11 gotoxy ." Enter a filename: "
  47.   filename 1+ 75 expect swap 1- c!              \ Get help file name.
  48.   " .hlp" count 1+ 0 do                         \ Add a .hlp extention.
  49.     dup i + c@ filename dup c@ + i 1+ + c!
  50.   loop
  51.   drop filename 1+ newfile hn !                 \ Open helpfile, save handle.
  52.   " .tmp" count 1+ 0 do                         \ Add a .tmp extention.
  53.     dup i + c@ filename dup c@ + i 1+ + c!
  54.   loop
  55.   drop filename 1+ newfile ht !                 \ Open tmpfile, save handle.
  56.   20 table.length !                             \ First entry is bogus.
  57.   0 len !                                       \ Reset offset to zero.
  58.   " hold" 1+ 4 hn @ write drop drop             \ Save place for table length.
  59.   "                     " 1+ 16 hn @ write drop drop  \ First entry null.
  60.   len 4 hn @ write drop drop                    \ Save a zero length
  61. ;                                               \      for first entry.
  62. ~UP
  63. CREATE BUFFER
  64. EDIT
  65. \ An entry is limited to 32K.
  66. create buffer 1024 32 * allot
  67. ~UP
  68. CREATE CLEANUP
  69. EDIT
  70. \ Merges files, deletes intermediate files, fixes up table length, etc.
  71. : cleanup
  72.   0 0 ht @ seek
  73.   if drop else ." Seek error (build)" abort endif
  74.   buffer 1024 32 * ht @ read drop
  75.   buffer swap hn @ write
  76.   if else
  77.     ." Write error! (build)" abort
  78.   endif
  79.   drop
  80.   0 0 hn @ seek
  81.   if drop else ." Seek error (build)" abort endif
  82.   table.length 4 hn @ write drop drop
  83.   " text.hlp" 1+ delete if else drop endif
  84.   hn @ close if else drop endif                         \ Close files.
  85.   ht @ close if else drop endif
  86.   filename 1+ delete if else drop endif                 \ Delete tmp file.
  87. ;
  88. ~UP
  89. CREATE TRY
  90. EDIT
  91. | try
  92.  
  93. TRY
  94. This is a test of the American broadcast system.
  95. ~UP
  96. CREATE PRINT
  97. CREATE SKIPWHITE
  98. EDIT
  99. \ (  Hard.addr -> Hard.addr )
  100. \ Skips to first non white character.
  101. : skipwhite
  102. begin
  103.   dup  c@@ 32 =
  104.   over c@@ 13 = or
  105.   over c@@ 10 = or
  106.   over c@@ 09 = or
  107. while
  108.   1+
  109. repeat
  110. ;
  111. ~UP
  112. CREATE WRITE.KEY
  113. EDIT
  114. \ Write out the key to the entry.
  115. \ ( Hard.addr -> hard.addr )
  116. : write.key
  117.   40 0 do 32 buffer i + c! loop         \ Space-out the buffer...
  118.   0 buffer c!                           \ Start at buffer beginning.
  119.   begin
  120.     dup  c@@ 13 =                       \ While not whitespace,
  121.     over c@@ 10 = or
  122.     over c@@  9 = or
  123.     over c@@ 32 = or
  124.     over c@@  0 = or
  125.   not while
  126.     dup c@@                             \ Get a character,
  127.     dup 96 > over 123 < and if 32 - endif   \ Convert to upper case.
  128.     buffer dup c@ + 1+ c!               \ Add to the buffer.
  129.     1+                                  \ Inc the hard address.
  130.     1 buffer c@ + buffer c!             \ Inc the Buffer count.
  131.   repeat
  132.   buffer 16 hn @ write drop drop        \ Write out the key.
  133.   20 table.length +!                    \ Increment table length.
  134. ;
  135. ~UP
  136. CREATE WRITE.DEF
  137. EDIT
  138. \ Write out the definition to the temp file.
  139. \ ( Hard.addr -> hard.addr )
  140. : write.def
  141.   0 buffer !                            \ Start at buffer beginning.
  142.   begin
  143.     dup  c@@                            \ While not null...
  144.   while
  145.     dup c@@ buffer dup @ + 4 + c!       \ Add to the buffer.
  146.     1+                                  \ Inc the hard address.
  147.     1 buffer +!                         \ Inc the Buffer count.
  148.   repeat
  149.   buffer 4 + buffer @ ht @ write drop drop  \ Write out the definition.
  150.   buffer @ len +!                       \ Increment length.
  151.   len 4 hn @ write drop drop            \ Write out offset into the table.
  152. ;
  153. ~UP
  154. EDIT
  155. ( execution.address -> )
  156. : print
  157.   >body                         \ Goto data area.
  158.   dup @ 77777777 = not if       \ Test Marker.
  159.     ." Invalid entry found!!"
  160.   abort endif
  161.   8 + @                         \ Get HARDWARE address of text.
  162.   skipwhite                     \ Skip Whitespace.
  163.   dup c@@ 0= if                 \ If no token follows, ignore the entry.
  164.     drop exit
  165.   endif
  166.   write.key                     \ Write out the Entry name.
  167.   write.def                     \ Write out the definition.
  168.   drop
  169. ;
  170. ~UP
  171. CREATE PRINT.ALL
  172. EDIT
  173. \ Prints recursively all entries below and beside the given entry.
  174. \ ( exececution.addr  -> )
  175. : print.all
  176.   dup 0= if drop exit endif     \ Test if execution address is good.
  177.   dup comp                      \ If so, compile this module,
  178.   dup print                     \        print this module,
  179.   dup child print.all           \        print its children,
  180.       next  print.all           \        print the next module.
  181. ;
  182. ~UP
  183. EDIT
  184. \ Used to define an entry into the help file.  Executing an entry will
  185. \ generate a helpfile consisting of the particular entry, and all its
  186. \ children.
  187.  
  188. : |
  189.   >in @                 \ Save the start of the module.
  190.   create                \ Create the module.
  191.   >in !                 \ Reset the start of the module.
  192.   77777777 ,            \ Save a marker for Print to use as a validity test.
  193.   ' ,                   \ Save the execution address of the module.
  194.   >in @ ,               \ Save a HARDWARE pointer to the text of the module.
  195.   0 buffer !            \ Kill the compilation.
  196.   buffer i->d >in !     \
  197. does>
  198.   openfiles
  199.   4 + @ dup print       \ Write out this module
  200.   child print.all       \ Print out all children.
  201.   cleanup               \ Fix up the files.
  202. ;
  203. ~UP
  204. CREATE BUILD-HELP-FILE
  205. CREATE ARITHMETIC
  206. CREATE MAX
  207. EDIT
  208. | MAX
  209.  
  210. MAX
  211. (32b1 32b2 -> 32b3) Leave the larger of 32b1 and 32b2 on the stack as 32b3."
  212. ~UP
  213. CREATE MIN
  214. EDIT
  215. | MIN
  216.  
  217. MIN
  218. (32b1 32b2 -> 32b3) Leave the lesser of 32b1 and 32b2 on the stack as 32b3."
  219. ~UP
  220. CREATE F->I
  221. EDIT
  222. | F->I
  223.  
  224. F->I
  225. (32b1 -> 32b2) Converts floating point to integer, numerical overflow if
  226. 32b1 cannot be represented as an integer."
  227. ~UP
  228. CREATE I->F
  229. EDIT
  230. | I->F
  231.  
  232. I->F
  233. (32b1 -> 32b2 ) Convert integer to floating point."
  234. ~UP
  235. CREATE ABS
  236. EDIT
  237. | ABS
  238.  
  239. ABS
  240. (32b -> u32b) Signed 32b is replaced by it's absolute value."
  241. ~UP
  242. CREATE -
  243. EDIT
  244. | -
  245.  
  246. -
  247. (32b1 32b2 -> 32b3) Subtract 32b2 from 32b1 yielding 32b3."
  248. ~UP
  249. CREATE SHL
  250. EDIT
  251. | SHL
  252.  
  253. SHL
  254. (32b1 32b2 -> 32b3) 32b1 is shifted left 32b2 places, zeros are shifted in on
  255. the right. The result is 32b3."
  256. ~UP
  257. CREATE SHR
  258. EDIT
  259. | SHR
  260.  
  261. SHR
  262. (32b1 32b2 -> 32b3) 32b1 is shifted right 32b2 places, zeros are shifted in on
  263. the left. The result is 32b3."
  264. ~UP
  265. CREATE MOD
  266. EDIT
  267. | MOD
  268.  
  269. MOD
  270. (32b1 32b2 -> 32b3) Divide 32b1 by 32b2 yielding remainder 32b3. 32b3 has
  271. same sign as 32b2, forces an error if 32b2 is zero or quotient out of range."
  272. ~UP
  273. CREATE NEGATE
  274. EDIT
  275. | NEGATE
  276.  
  277. NEGATE
  278. (32b1 -> 32b2) Two's complement 32b1 yielding 32b2."
  279. ~UP
  280. CREATE 2/
  281. EDIT
  282. | 2/
  283.  
  284. 2/
  285. (32b1 -> 32b2) Arithmetically shift 32b1 right 1 yielding 32b2."
  286. ~UP
  287. CREATE 2-
  288. EDIT
  289. | 2-
  290.  
  291. 2-
  292. (32b1 -> 32b2) Subtract 2 from 32b1 yielding 32b2."
  293. ~UP
  294. CREATE 2+
  295. EDIT
  296. | 2+
  297.  
  298. 2+
  299. (32b1 -> 32b2) Add 2 to 32b1 yielding 32b2."
  300. ~UP
  301. CREATE 1-
  302. EDIT
  303. | 1-
  304.  
  305. 1-
  306. (32b1 -> 32b2) Decrement 32b1 yielding 32b2."
  307. ~UP
  308. CREATE 1+
  309. EDIT
  310. | 1+
  311.  
  312. 1+
  313. (32b1 -> 32b2) Increment 32b1 yielding 32b2."
  314. ~UP
  315. CREATE *
  316. EDIT
  317. | *
  318.  
  319. *
  320. (32b1 32b2 -> 32b3) Signed multiply of 32b1 times 32b2 yielding 32b3."
  321. ~UP
  322. CREATE +
  323. EDIT
  324. | +
  325.  
  326. +
  327. (32b1 32b2 -> 32b3) Add 32b1 to 32b2 yielding 32b3."
  328. ~UP
  329. CREATE /MOD
  330. EDIT
  331. | /MOD
  332.  
  333. /MOD
  334. (32b1 32b2 -> 32b3 32b4) Divide 32b1 by 32b2, leaving quotient 32b4 and
  335. remainder 32b3. 32b3 has same sign as 32b2 Numerical overflow if 32b2 is zero
  336. or 32b4 out of range."
  337. ~UP
  338. CREATE /
  339. EDIT
  340. | /
  341.  
  342. /
  343. (32b1 32b2 -> 32b3) Divide 32b1 by 32b2, leaving quotient 32b3. Numerical
  344. overflow if 32b2 is zero or 32b3 out of range."
  345. ~UP
  346. CREATE F/
  347. EDIT
  348. | F/
  349.  
  350. F/
  351. (32b1 32b2 -> 32b3 ) Divides two floating point numbers."
  352. ~UP
  353. CREATE F*
  354. EDIT
  355. | F*
  356.  
  357. F*
  358. (32b1 32b2 -> 32b3 ) Multiplies two floating point numbers."
  359. ~UP
  360. CREATE F-
  361. EDIT
  362. | F-
  363.  
  364. F-
  365. (32b1 32b2 -> 32b3 ) Subtracts two floating point numbers."
  366. ~UP
  367. CREATE F+
  368. EDIT
  369. | F+
  370.  
  371. F+
  372. (32b1 32b2 -> 32b3 ) Adds two floating point numbers."
  373. ~UP
  374. CREATE FEXP
  375. EDIT
  376. | FEXP
  377.  
  378. FEXP
  379. (32b1 -> 32b2) Returns e^X on floating point number 32b1."
  380. ~UP
  381. CREATE FLOG
  382. EDIT
  383. | FLOG
  384.  
  385. FLOG
  386. (32b1 -> 32b2) Returns the natural log of 32b1."
  387. ~UP
  388. EDIT
  389. | arithmetic
  390.  
  391. arithmetic
  392.  
  393. Fifth supports 32-bit integer and floating point
  394. arithmetic.  The floating point operators rely
  395. on the math coprocessor, and thus will not work
  396. on some Systems.  The following is a summary of
  397. the Fifth arithmetic primitives:
  398.  
  399. INTEGER:   +       -       *       /       /MOD
  400.            2*      2/      1+      1-      2+
  401.            2-      SHR     SHL     ABS     NEGATE
  402.            MAX     MIN
  403.  
  404. FLOATING POINT:    F+      F-      F*      F/
  405.                    FLOG    FEXP
  406.  
  407. CONVERSION:        F->I    I->F
  408. ~UP
  409. CREATE I/O
  410. CREATE CLOSE
  411. EDIT
  412. | CLOSE
  413.  
  414. CLOSE
  415. (32b1 -> -1) or (32b1 -> 32b2 0) Close file with handle 32b1. Returns true
  416. flag if no error. Returns false flag and error code 32b2 if error."
  417. ~UP
  418. CREATE CREATEFILE
  419. EDIT
  420. | CREATEFILE
  421.  
  422. CREATEFILE
  423. (addr 32b1 -> 32b2 -1) or (addr 32b1 -> 32b2  0) Create file with name at
  424. address and attributes 32b1. 32b1 is 1 = read only, 2 = hidden, 4 = system, 20h
  425. = archive. Sum bits for multiple attributes. 32b2 is the file handle, unless an
  426. error occurred, then 32b2 is the error code."
  427. ~UP
  428. CREATE DELETE
  429. EDIT
  430. | DELETE
  431.  
  432. DELETE
  433. (addr -> -1) or (addr -> 32b1 0) Deletes file with name at address. Returns
  434. a true flag, or error code 32b1 and a false flag."
  435. ~UP
  436. CREATE OPEN
  437. EDIT
  438. | OPEN
  439.  
  440. OPEN
  441. (addr 8b -> 32b1 -1) or (addr 8b -> 32b2 0) Opens existing file with name at
  442. address. 8b is 0 for read, 1 for write, 2 for read and write. Returns 32b1 as
  443. file handle and true flag, or 32b2 as error code and false flag. The 32b1
  444. handle will be used in all I/O with the file."
  445. ~UP
  446. CREATE READ
  447. EDIT
  448. | READ
  449.  
  450. READ
  451. (addr 32b1 32b2 -> 32b3 -1) or (addr 32b1 32b2 -> 32b3 0) The buffer at
  452. address is filled with 32b1 bytes from file with handle 32b2. 32b3 is the
  453. number of bytes actually read, unless an error occurred. Then 32b3 is the
  454. error code."
  455. ~UP
  456. CREATE RENAME
  457. EDIT
  458. | RENAME
  459.  
  460. RENAME
  461. (addr1 addr2 -> -1) or (addr1 addr2 -> 32b1 0) File with name at addr1 is
  462. renamed to name at addr2. Returns a true flag, or error code 32b1 and false
  463. flag."
  464. ~UP
  465. CREATE SEEK
  466. EDIT
  467. | SEEK
  468.  
  469. SEEK
  470. (32b1 8b 32b2 -> 32b3 -1) or (32b1 8b 32b2 -> 32b4 0) Moves file pointer 32b1
  471. bytes from offset specified in 8b, in file with handle 32b2. Returns new file
  472. pointer position 32b3 and a true flag, or error code 32b4 and a false flag. If
  473. 8b = 0 then offset is from file beginning, if 8b = 1 then offset is from the
  474. current position, if 8b = 2 then offset is from end of file."
  475. ~UP
  476. CREATE WRITE
  477. EDIT
  478. | WRITE
  479.  
  480. WRITE
  481. (addr 32b1 32b2 -> 32b3 -1) or (addr 32b1 32b2 -> 32b3  0) Write buffer at
  482. address.  Buffer length written is 32b1 bytes.  File handle is 32b2.  32b3 is
  483. the number of bytes written followed by -1, or 32b3 is an error number followed
  484. by 0."
  485. ~UP
  486. CREATE ?TERM
  487. EDIT
  488. | ?TERM
  489.  
  490. ?TERM
  491. ( -> flag) Leave a true flag if a character is available at the keyboard,
  492. otherwise leave a false flag."
  493. ~UP
  494. CREATE CLS
  495. EDIT
  496. | CLS
  497.  
  498. CLS
  499. ( -> ) Clear the screen and home the cursor."
  500. ~UP
  501. CREATE CR
  502. EDIT
  503. | CR
  504.  
  505. CR
  506. ( -> ) Sends a carriage-return line-feed pair to the terminal."
  507. ~UP
  508. CREATE EMIT
  509. EDIT
  510. | EMIT
  511.  
  512. EMIT
  513. (8b -> ) The 8b value is sent to the terminal."
  514. ~UP
  515. CREATE EXPECT
  516. EDIT
  517. | EXPECT
  518.  
  519. EXPECT
  520. (addr 8b1 -> addr 8b2) Read 8b1 characters at addr or until a CR, with
  521. backspace editing. 8b2 is the number of characters read."
  522. ~UP
  523. CREATE GOTOXY
  524. EDIT
  525. | GOTOXY
  526.  
  527. GOTOXY
  528. ( 32b1 32b2 -> ) Moves the cursor to column 32b1, row 32b2."
  529. ~UP
  530. CREATE KEY
  531. EDIT
  532. | KEY
  533.  
  534. KEY
  535. ( -> 8b) Wait for a character from the keyboard, do not echo it."
  536. ~UP
  537. CREATE QUERY
  538. EDIT
  539. | QUERY
  540.  
  541. QUERY
  542. ( -> ) Causes the input buffer to be flushed and read."
  543. ~UP
  544. CREATE SCREEN
  545. EDIT
  546. | SCREEN
  547.  
  548. SCREEN
  549. ( -> 32b) Returns the indirect address of the current video text screen.
  550. SCREEN is compatible with such primitives as FILL and MOVE. On the IBM, SCREEN
  551. keeps track of the correct screen for both black & white and color screens."
  552. ~UP
  553. CREATE SPACE
  554. EDIT
  555. | SPACE
  556.  
  557. SPACE
  558. ( -> ) Output a space to the terminal."
  559. ~UP
  560. CREATE SPAN
  561. EDIT
  562. | SPAN
  563.  
  564. SPAN
  565. ( -> addr) Addr is the address of the length of the last data read with
  566. EXPECT."
  567. ~UP
  568. CREATE SPACES
  569. EDIT
  570. | SPACES
  571.  
  572. SPACES
  573. (32b -> ) Output 32b spaces to the terminal."
  574. ~UP
  575. CREATE TIB
  576. EDIT
  577. | TIB
  578.  
  579. TIB
  580. ( -> addr) Leaves the address the start of the terminal input buffer on the
  581. stack."
  582. ~UP
  583. CREATE CONVERT
  584. EDIT
  585. | CONVERT
  586.  
  587. CONVERT
  588. (addr1 -> addr2 32b) The string whose length byte is pointed to by address #1
  589. is converted to 32b. Address #2 points to the first non-convertible character.
  590. DPL is a -1 for a integer, and >= 0 for a floating point number."
  591. ~UP
  592. CREATE COUNT
  593. EDIT
  594. | COUNT
  595.  
  596. COUNT
  597. (addr1 -> addr2 8b) The string whose length byte is pointed to by address #1
  598. has it's length byte pushed onto the stack, address #1 is incremented yielding
  599. address #2."
  600. ~UP
  601. CREATE DPL
  602. EDIT
  603. | DPL
  604.  
  605. DPL
  606. ( -> addr ) The address of the number of trailing digits in the last double
  607. precision number, or a -1 if integer, is left on the stack."
  608. ~UP
  609. CREATE TYPE
  610. EDIT
  611. | TYPE
  612.  
  613. TYPE
  614. (addr +n -> ) +n characters from the string at address are echoed to the
  615. terminal."
  616. ~UP
  617. CREATE SIGN
  618. EDIT
  619. | SIGN
  620.  
  621. SIGN
  622. (32b -> ) Place a sign '-' character in the formatted string buffer if 32b is
  623. less than zero."
  624. ~UP
  625. CREATE HOLD
  626. EDIT
  627. | HOLD
  628.  
  629. HOLD
  630. (8b -> ) Pushes the 8b character into the formatted string buffer."
  631. ~UP
  632. CREATE PAD
  633. EDIT
  634. | PAD
  635.  
  636. PAD
  637. ( -> addr) Leaves the address of the start of the formatted string buffer on
  638. the stack."
  639. ~UP
  640. CREATE F->EM
  641. EDIT
  642. | F->EM
  643.  
  644. F->EM
  645. (32b1 -> 32b2 32b3) Converts the floating point 32b1 to exponent 32b2 and
  646. mantissa 32b3. Mantissa is adjusted by RADIX to the 6th power, to allow six #'s
  647. to be used on it within a formatted string command sequence."
  648. ~UP
  649. CREATE F.
  650. EDIT
  651. | F.
  652.  
  653. F.
  654. (32b -> ) Prints the floating point number."
  655. ~UP
  656. CREATE U.
  657. EDIT
  658. | U.
  659.  
  660. U.
  661. (u32b -> ) The unsigned integer u32b is printed."
  662. ~UP
  663. CREATE <#
  664. EDIT
  665. | <#
  666.  
  667. <#
  668. ( -> ) Reset the formatted string length and pointer."
  669. ~UP
  670. CREATE .S
  671. EDIT
  672. | .S
  673.  
  674. .S
  675. (32b1 32b2 ... -> ) Print all values on stack as signed integer values."
  676. ~UP
  677. CREATE .(
  678. EDIT
  679. | .(
  680.  
  681. .(
  682. ( -> ) Following string is immediately displayed, until the terminating
  683. parenthesis."
  684. ~UP
  685. CREATE .
  686. EDIT
  687. | .
  688.  
  689. .
  690. (32b -> ) Signed integer number is printed in the current radix with a
  691. trailing blank."
  692. ~UP
  693. CREATE ."
  694. EDIT
  695. | ."
  696.  
  697. ."
  698. ( -> ) Following string is compiled inline for later display. String is
  699. terminated by a quote."
  700. ~UP
  701. CREATE -TRAILING
  702. EDIT
  703. | -TRAILING
  704.  
  705. -TRAILING
  706. (addr +8b1 -> addr +8b2) All trailing blanks from string at address are
  707. removed, the new length is left on the stack."
  708. ~UP
  709. CREATE #TIB
  710. EDIT
  711. | #TIB
  712.  
  713. #TIB
  714. ( -> addr) Leaves address of terminal input buffer, first byte is length,
  715. next is buffer. Use C@ or COUNT to get the length."
  716. ~UP
  717. CREATE #S
  718. EDIT
  719. | #S
  720.  
  721. #S
  722. (+32b -> 0 ) All remaining digits of 32b are placed in the formatted string
  723. buffer."
  724. ~UP
  725. CREATE #>
  726. EDIT
  727. | #>
  728.  
  729. #>
  730. (32b -> addr +n ) Number on stack is replaced by the address and
  731. length of the formatted string buffer."
  732. ~UP
  733. CREATE #
  734. EDIT
  735. | #
  736.  
  737. #
  738. (+32b1 -> +32b2 ) Positive number +32b1 is divided by the current radix. The
  739. remainder is converted to a digit and stuffed into the formatted string buffer.
  740. The quotient is left on the stack."
  741. ~UP
  742. EDIT
  743. | i/o
  744.  
  745. I/O
  746. I/O is a diverse subject, Fifth lumps I/O primitives under these headings:
  747.  
  748. Disk I/O:       CLOSE           CREATEFILE      DELETE
  749.                 OPEN            READ            RENAME
  750.                 SEEK            WRITE
  751.  
  752. Screen I/O:     ?TERM           CLS             CONVERT
  753.                 CR              DPL             EMIT
  754.                 EXPECT          GOTOXY          KEY
  755.                 QUERY           SCREEN          SPACE
  756.                 SPACES          SPAN            TIB
  757.                 #TIB
  758. String
  759. formatting:     <#              #               #>
  760.                 #S              HOLD            F->EM
  761.                 PAD             SIGN            -TRAILING
  762.  
  763. Printing:       .               .(              ."
  764.                 .S              COUNT           F.
  765.                 TYPE            U.
  766. ~UP
  767. CREATE GRAPHICS
  768. CREATE VMODE
  769. EDIT
  770. | VMODE
  771.  
  772. VMODE
  773. ( 32b1 -> ) On the IBM, the 32b1 is the screen mode, both black & white and
  774. color screens are supported. On the TI, 32b1 is ignored, and the screen palette
  775. is reset."
  776. ~UP
  777. CREATE PALETTE
  778. EDIT
  779. | PALETTE
  780.  
  781. PALETTE
  782. ( 32b1 32b2 -> ) On the IBM, 32b1 is the background color, and 32b2 is either
  783. 0 or 1. On the TI 32b1 is pixel value (0-7) and 32b2 is the color it is being
  784. mapped to (0-7)."
  785. ~UP
  786. CREATE PGET
  787. EDIT
  788. | PGET
  789.  
  790. PGET
  791. ( x1 y2 -> color ) Returns the color of a point."
  792. ~UP
  793. CREATE PSET
  794. EDIT
  795. | PSET
  796.  
  797. PSET
  798. ( color x1 y1 -> ) Set a point."
  799. ~UP
  800. CREATE PAINT
  801. EDIT
  802. | PAINT
  803.  
  804. PAINT
  805. ( x1 y1 color1 color2 -> ) Starting at x1,y1, fill the screen with color1,
  806. stopping on both color boundaries."
  807. ~UP
  808. CREATE MOVETO
  809. EDIT
  810. | moveto
  811.  
  812. MOVETO
  813. (x y -> ) Sets the current graphics draw point.
  814. ~UP
  815. CREATE POINT
  816. EDIT
  817. | point
  818.  
  819. POINT
  820. ( -> x y) Gets the current graphics draw point.
  821. ~UP
  822. CREATE LINETO
  823. EDIT
  824. | LINETO
  825.  
  826. LINETO
  827. ( color x y ) Draws a line from the current draw point to x,y. Sets x,y
  828. as the new draw point.
  829. ~UP
  830. CREATE FILLBOX
  831. EDIT
  832. | FILLBOX
  833.  
  834. FILLBOX
  835. ( color x1 y1 x2 y2 -> ) Fills a box."
  836. ~UP
  837. CREATE BOX
  838. EDIT
  839. | BOX
  840.  
  841. BOX
  842. ( color x1 y1 x2 y2 -> ) Draws a box."
  843. ~UP
  844. EDIT
  845. | graphics
  846.  
  847. GRAPHICS
  848. The following words are available for graphics in Fifth:
  849.  
  850.         BOX             FILLBOX         PAINT
  851.         PALETTE         PSET            PGET
  852.         MOVETO          POINT           LINETO
  853.         VMODE
  854. ~UP
  855. CREATE COND_COMP
  856. CREATE }REPEAT
  857. EDIT
  858. | }REPEAT
  859.  
  860. }REPEAT
  861. ( -> ) The text pointer is reset to just after an enclosing BEGIN{.
  862. NOTE: }REPEAT is immediate."
  863. ~UP
  864. CREATE }WHILE{
  865. EDIT
  866. | }WHILE{
  867.  
  868. }WHILE{
  869. ( flag -> ) If the flag is true, execution proceeds. If false, the return stack
  870. is popped, and execution proceeds after the enclosing }REPEAT.
  871. NOTE: }WHILE{ is immediate."
  872. ~UP
  873. CREATE }UNTIL
  874. EDIT
  875. | }UNTIL
  876.  
  877. }UNTIL
  878. ( flag -> ) If the flag is true, the return stack is popped and execution
  879. continues. If false, the text pointer is reset to just after an enclosing
  880. BEGIN{. NOTE }UNTIL is immediate."
  881. ~UP
  882. CREATE BEGIN{
  883. EDIT
  884. | BEGIN{
  885.  
  886. BEGIN{
  887. ( -> ) Saves the text pointer on the return stack, used with }UNTIL or }WHILE{
  888. }REPEAT. NOTE BEGIN{ is immediate."
  889. ~UP
  890. CREATE }LOOP
  891. EDIT
  892. | }LOOP
  893.  
  894. }LOOP
  895. ( -> ) Bumps the index provided by DO{, and checks it versus the terminator. If
  896. index equals the terminator, processing continues. If not, the text pointer is
  897. reset to just after the DO{. Use R@ to get the index. NOTE: }LOOP is immediate.
  898. "
  899. ~UP
  900. CREATE DO{
  901. EDIT
  902. | DO{
  903.  
  904. DO{
  905. ( 32b1 32b2 -> ) The index is set to 32b2, and increments to 32b1. Text upto
  906. the enclosing }LOOP is repeated (reparsed). The value of the index, terminator
  907. and loop address is kept on the return stack. NOTE: DO{ is immediate."
  908. ~UP
  909. CREATE }ENDIF
  910. EDIT
  911. | }ENDIF
  912.  
  913. }ENDIF
  914. ( -> ) Place marker for IF{ and }ELSE{ modules. This module does nothing."
  915. ~UP
  916. CREATE }ELSE{
  917. EDIT
  918. | }ELSE{
  919.  
  920. }ELSE{
  921. ( -> ) Skips text to the next }ENDIF. NOTE: }ELSE{ is immediate."
  922. ~UP
  923. CREATE IF{
  924. EDIT
  925. | IF{
  926.  
  927. IF{
  928. ( flag -> ) If the flag is true, execution proceeds. If the flag is false, text
  929. is skipped till the next }ELSE{ or }ENDIF. NOTE: IF{ is immediate."
  930. ~UP
  931. EDIT
  932. | cond_comp
  933.  
  934. CONDITIONAL
  935. Fifth allows conditional compilation.  These modules
  936. are written in Fifth themselves.  They allow the
  937. program to make decisions at compile time, or in
  938. the interactive environment.
  939.  
  940.         BEGIN{     }WHILE{     }REPEAT    }UNTIL
  941.         DO{        }LOOP
  942.         IF{        }ELSE{      }ENDIF
  943. ~UP
  944. CREATE STRUCTURES
  945. CREATE @
  946. EDIT
  947. | @
  948.  
  949. @
  950. (addr -> 32b) The 32b value at the address is fetched."
  951. ~UP
  952. CREATE C@
  953. EDIT
  954. | C@
  955.  
  956. C@
  957. (addr -> 8b) 8b value is fetched from the address, the high bytes are set to
  958. zero and placed on the stack as a 32b value."
  959. ~UP
  960. CREATE C@@
  961. EDIT
  962. | C@@
  963.  
  964. C@@
  965. (32b -> 8b) The 8b value at the direct hardware address 32b is fetched."
  966. ~UP
  967. CREATE C!!
  968. EDIT
  969. | C!!
  970.  
  971. C!!
  972. ( 8b 32b -> ) Store the 8b value at the 32b direct hardware address."
  973. ~UP
  974. CREATE C!
  975. EDIT
  976. | C!
  977.  
  978. C!
  979. (8b addr -> ) 8b value is stored at address."
  980. ~UP
  981. CREATE 2@
  982. EDIT
  983. | 2@
  984.  
  985. 2@
  986. (addr -> 64b ) Fetch the 64b value stored at the address."
  987. ~UP
  988. CREATE 2!
  989. EDIT
  990. | 2!
  991.  
  992. 2!
  993. (64b addr -> ) Store the 64b value into the address."
  994. ~UP
  995. CREATE +!
  996. EDIT
  997. | +!
  998.  
  999. +!
  1000. (32b addr -> ) Add 32b to the value at the address."
  1001. ~UP
  1002. CREATE !
  1003. EDIT
  1004. | !
  1005.  
  1006. !
  1007. ( 32b addr -> ) Store the 32b value at the address."
  1008. ~UP
  1009. CREATE I->D
  1010. EDIT
  1011. | I->D
  1012.  
  1013. I->D
  1014. (addr -> 32b) Convert indirect address to a direct hardware 32b address."
  1015. ~UP
  1016. CREATE IF
  1017. EDIT
  1018. | IF
  1019.  
  1020. IF
  1021. (flag -> ) Used in a test IF true-body ENDIF or test IF true-body ELSE false-
  1022. body ENDIF construct. Branches according to whether the flag is zero or non-
  1023. zero."
  1024. ~UP
  1025. CREATE ELSE
  1026. EDIT
  1027. | ELSE
  1028.  
  1029. ELSE
  1030. ( -> ) Used in a test IF true-body ELSE false-body ENDIF construct."
  1031. ~UP
  1032. CREATE ENDIF
  1033. EDIT
  1034. | ENDIF
  1035.  
  1036. ENDIF
  1037. ( -> ) Used inside a test IF true-body ENDIF or test IF true-body ELSE false-
  1038. body ENDIF construct."
  1039. ~UP
  1040. CREATE BEGIN
  1041. EDIT
  1042. | BEGIN
  1043.  
  1044. BEGIN
  1045. ( -> ) Marks the beginning of a BEGIN body test UNTIL loop or a BEGIN test
  1046. WHILE body REPEAT loop."
  1047. ~UP
  1048. CREATE WHILE
  1049. EDIT
  1050. | WHILE
  1051.  
  1052. WHILE
  1053. (flag -> ) Used to test for loop termination in a BEGIN test WHILE body
  1054. REPEAT loop. If the flag is false the loop is exited past the REPEAT."
  1055. ~UP
  1056. CREATE UNTIL
  1057. EDIT
  1058. | UNTIL
  1059.  
  1060. UNTIL
  1061. (flag -> ) Loops to enclosing BEGIN if flag is false, otherwise the loop
  1062. terminates. Used in BEGIN body test UNTIL loops."
  1063. ~UP
  1064. CREATE REPEAT
  1065. EDIT
  1066. | REPEAT
  1067.  
  1068. REPEAT
  1069. ( -> ) Causes a loop to an enclosing BEGIN in a BEGIN test WHILE body REPEAT
  1070. construct."
  1071. ~UP
  1072. CREATE VARIABLE
  1073. EDIT
  1074. | VARIABLE
  1075.  
  1076. VARIABLE
  1077. ( -> ) The next module in the input stream is CREATE'd, and 4 bytes reserved
  1078. for it's use."
  1079. ~UP
  1080. CREATE CONSTANT
  1081. EDIT
  1082. | CONSTANT
  1083.  
  1084. CONSTANT
  1085. (32b -> ) Next module in the input stream is compiled into the dictionary.
  1086. Later execution of this name leaves 32b on the stack."
  1087. ~UP
  1088. CREATE NEW
  1089. EDIT
  1090. | NEW
  1091.  
  1092. NEW
  1093. ( -> addr) Creates a module, exactly as CREATE does, except the name is always
  1094. a '■' a special character).  Returns addr as the parameter area.  Used for
  1095. dynamic storage allocation to the HEAP."
  1096. ~UP
  1097. CREATE DISPOSE
  1098. EDIT
  1099. | DISPOSE
  1100.  
  1101. DISPOSE
  1102. (addr -> ) Deletes module with parameter area address, and all sub-modules and
  1103. related text. Does not mark following modules as 'Not Compiled' , therefore it
  1104. should not be used to delete code modules. Usually used to remove modules
  1105. created by NEW."
  1106. ~UP
  1107. CREATE SCAN
  1108. EDIT
  1109. | SCAN
  1110.  
  1111. SCAN
  1112. ( addr 32b1 8b -> 32b2 ) Scan 32b1 bytes at addr for 8b. Return 32b2 as offset
  1113. + 1 of first occurance of byte 8b in addr. Return 0 if byte not found in 32b1
  1114. characters. If byte is first character, 32b2 is 1."
  1115. ~UP
  1116. CREATE DO
  1117. EDIT
  1118. | DO
  1119.  
  1120. DO
  1121. (32b1 32b2 -> ) Move 32b1 and 32b2 to the return stack. 32b2 is the initial
  1122. value and 32b1 is the limit. All code between the DO and the LOOP or +LOOP is
  1123. repeat until the index crosses the (limit-1)  to (limit) boundary."
  1124. ~UP
  1125. CREATE I
  1126. EDIT
  1127. | I
  1128.  
  1129. I
  1130. ( -> 32b) Leaves the value of the innermost DO index on the stack."
  1131. ~UP
  1132. CREATE J
  1133. EDIT
  1134. | J
  1135.  
  1136. J
  1137. ( -> 32b) Leaves the value of the second innermost DO index on the stack."
  1138. ~UP
  1139. CREATE LEAVE
  1140. EDIT
  1141. | LEAVE
  1142.  
  1143. LEAVE
  1144. ( -> ) Causes the innermost DO body LOOP construct to be exited immediately."
  1145. ~UP
  1146. CREATE LOOP
  1147. EDIT
  1148. | LOOP
  1149.  
  1150. LOOP
  1151. ( -> ) Increments the loop index by one, in a DO body LOOP construct. If the
  1152. index crosses the (limit-1) to (limit) boundary, then the index and limit are
  1153. removed from the return stack and the loop is terminated, otherwise loops to
  1154. the DO."
  1155. ~UP
  1156. CREATE +LOOP
  1157. EDIT
  1158. | +LOOP
  1159.  
  1160. +LOOP
  1161. (n -> ) Add the value n to the loop index, if the index crossed the (limit -
  1162. 1) to (limit) boundary terminate, otherwise loop to the enclosing DO. The index
  1163. and limit values are on the return stack."
  1164. ~UP
  1165. CREATE EXIT
  1166. EDIT
  1167. | EXIT
  1168.  
  1169. EXIT
  1170. ( -> ) Exits the current module, >R and R> modules must be balanced, but
  1171. DO/LOOP's do not."
  1172. ~UP
  1173. CREATE HERE
  1174. EDIT
  1175. | HERE
  1176.  
  1177. HERE
  1178. ( -> addr ) Leaves the address of the current top of dictionary."
  1179. ~UP
  1180. CREATE DOES>
  1181. EDIT
  1182. | DOES>
  1183.  
  1184. DOES>
  1185. ( -> ) Causes the address of the code following the DOES> to be placed in the
  1186. current module's indirect parameter address. UP is called, to restore the local
  1187. module from a previous CREATE. Later execution of a module CREATE'd with this
  1188. module
  1189. will execute the code following the DOES>. The current module's compilation is
  1190. completed without executing this code. "
  1191. ~UP
  1192. CREATE CMOVE>
  1193. EDIT
  1194. | CMOVE>
  1195.  
  1196. CMOVE>
  1197. (addr1 addr2 32b -> ) Move 32b bytes starting at (addr1 + 32b - 1) to (addr2
  1198. + 32b - 1) and proceeding toward low memory."
  1199. ~UP
  1200. CREATE CMOVE
  1201. EDIT
  1202. | CMOVE
  1203.  
  1204. CMOVE
  1205. (addr1 addr2 32b -> ) 32b characters from address #1 are moved to address
  1206. #2."
  1207. ~UP
  1208. CREATE ERASE
  1209. EDIT
  1210. | ERASE
  1211.  
  1212. ERASE
  1213. (addr 32b -> ) Zeros 32b bytes at addr."
  1214. ~UP
  1215. CREATE FILL
  1216. EDIT
  1217. | FILL
  1218.  
  1219. FILL
  1220. (addr 32b 8b -> ) From address, 32b bytes are filled with 8b."
  1221. ~UP
  1222. CREATE BLANK
  1223. EDIT
  1224. | BLANK
  1225.  
  1226. BLANK
  1227. (addr 32b -> ) Fills 32b bytes at addr with blanks."
  1228. ~UP
  1229. CREATE MOVE
  1230. EDIT
  1231. | MOVE
  1232.  
  1233. MOVE
  1234. (addr1 addr2 n -> ) Copy n words (32b values) from address #1 to address #2.
  1235. Do nothing if n is less than or equal to zero."
  1236. ~UP
  1237. CREATE >BODY
  1238. EDIT
  1239. | >BODY
  1240.  
  1241. >BODY
  1242. (addr1 -> addr2) Convert the execution address addr1 to a parameter field
  1243. address addr2."
  1244. ~UP
  1245. CREATE "
  1246. EDIT
  1247. | "
  1248.  
  1249. "
  1250. ( -> addr ) Compiles a string literal inline, up to the terminating quote.
  1251. Returns the address of the length byte of the literal."
  1252. ~UP
  1253. EDIT
  1254. | structures
  1255.  
  1256. STRUCTURES
  1257. Fetching and storing data is how Fifth deals with variables. The looping and
  1258. testing contructs let Fifth programs make decisions. The block operations are
  1259. fast primitives. The miscellanous sections contains CONSTANT and VARIABLE.
  1260.  
  1261. Fetching &
  1262. Storing:        +!              2!              2@
  1263.                 !               C!              C!!
  1264.                 @               C@              C@@
  1265.                 I->D
  1266.  
  1267. If & looping:   +LOOP           BEGIN           DO
  1268.                 ELSE            ENDIF           I
  1269.                 IF              J               LOOP
  1270.                 LEAVE           REPEAT          UNTIL
  1271.                 WHILE
  1272. Block
  1273. Operations:     >BODY           BLANK           CMOVE
  1274.                 CMOVE>          ERASE           FILL
  1275.                 MOVE            SCAN
  1276.  
  1277. Misc:           "               CONSTANT        DISPOSE
  1278.                 DOES>           EXIT            HERE
  1279.                 NEW             VARIABLE
  1280. ~UP
  1281. CREATE COMPILING
  1282. CREATE WORD
  1283. EDIT
  1284. | WORD
  1285.  
  1286. WORD
  1287. (8b -> addr) Parses the next module in the input stream delimited by 8b, tabs,
  1288. blanks, carriage-returns, line-feeds or nulls.  Leading whitespace and
  1289. delimiters are skipped, the word is left at address+1, with a count at
  1290. address. The count is zero if the input stream is empty."
  1291. ~UP
  1292. CREATE [
  1293. EDIT
  1294. | [
  1295.  
  1296. [
  1297. ( -> ) The compiler is turned off."
  1298. ~UP
  1299. CREATE ]
  1300. EDIT
  1301. | ]
  1302.  
  1303. ]
  1304. ( -> ) The compiler is turned on."
  1305. ~UP
  1306. CREATE [COMPILE]
  1307. EDIT
  1308. | [COMPILE]
  1309.  
  1310. [COMPILE]
  1311. ( -> ) Causes a call to the next module in the input stream to be generated
  1312. when the module containing [COMPILE] is run."
  1313. ~UP
  1314. CREATE [']
  1315. EDIT
  1316. | [']
  1317.  
  1318. [']
  1319. ( -> ) Compiles the execution address of next module in input stream as a
  1320. literal, later execution of code leaves the address on the stack."
  1321. ~UP
  1322. CREATE TRACE
  1323. EDIT
  1324. | TRACE
  1325.  
  1326. TRACE
  1327. ( -> ) TRACE moves the cursor to the screen top, and prints the stack and the
  1328. module about to be executed. If a space bar is hit, execution proceeds
  1329. normally, if ESC is hit ABORT is called. Other keys are ignored. If Trace is
  1330. set on from the DIR command, TRACE is called before each module in the module
  1331. being traced."
  1332. ~UP
  1333. CREATE TEXT
  1334. EDIT
  1335. | TEXT
  1336.  
  1337. TEXT
  1338. ( 8b -> ) Clears the PAD buffer, then reads from the input stream to the PAD
  1339. buffer until the 8b delimiter is found."
  1340. ~UP
  1341. CREATE STATE
  1342. EDIT
  1343. | STATE
  1344.  
  1345. STATE
  1346. ( -> addr ) Leaves the address of the compiler state. 0 is off, anything else
  1347. is on. This value must NOT be modified."
  1348. ~UP
  1349. CREATE FIND
  1350. EDIT
  1351. | FIND
  1352.  
  1353. FIND
  1354. (addr1 -> addr2 n) For a string with count byte at address #1, search for
  1355. matching module name in dictionary. If found addr2 is the indirect execution
  1356. address, n is 1 if immediate, -1 otherwise. If not found but the string is an
  1357. integer, then addr2 is the 32b value, and n is 2. If string is a floating point
  1358. number, addr2 is the value, and n is 3. If none of the above, then
  1359. addr2 = addr1 and n=0."
  1360. ~UP
  1361. CREATE LITERAL
  1362. EDIT
  1363. | LITERAL
  1364.  
  1365. LITERAL
  1366. (32b -> ) Causes the top-of-stack value to be compiled just as if it where an
  1367. inline number."
  1368. ~UP
  1369. CREATE EXECUTE
  1370. EDIT
  1371. | EXECUTE
  1372.  
  1373. EXECUTE
  1374. (addr -> ) The code at the address is executed."
  1375. ~UP
  1376. CREATE CHILD
  1377. EDIT
  1378. | CHILD
  1379.  
  1380. CHILD
  1381. (addr1 -> addr2) Returns the address addr2 of the first child of module
  1382. addr1."
  1383. ~UP
  1384. CREATE NEXT
  1385. EDIT
  1386. | NEXT
  1387.  
  1388. NEXT
  1389. (addr1 -> addr2) Returns the address addr2 of the next module after module
  1390. addr1."
  1391. ~UP
  1392. CREATE COMP
  1393. EDIT
  1394. | COMP
  1395.  
  1396. COMP
  1397. ( addr -> ) Compiles the module with execution address addr."
  1398. ~UP
  1399. CREATE ABORT
  1400. EDIT
  1401. | ABORT
  1402.  
  1403. ABORT
  1404. ( -> ) All stacks are reset, all buffers are cleared, all files are closed,
  1405. the radix is set to 10, input is from keyboard, the screen mode is reset and
  1406. the compiler turned off."
  1407. ~UP
  1408. CREATE QUIT
  1409. EDIT
  1410. | QUIT
  1411.  QUIT
  1412. ( -> ) Does a full reset like ABORT except the data stack is left untouched."
  1413. ~UP
  1414. CREATE ABORT"
  1415. EDIT
  1416. | ABORT"
  1417.  
  1418. ABORT"
  1419. ( flag -> ) If the flag is true, the following message is printed, and ABORT
  1420. is called."
  1421. ~UP
  1422. CREATE >IN
  1423. EDIT
  1424. | >IN
  1425.  
  1426. >IN
  1427. ( -> addr ) Leaves the address of the hardware pointer in the text input
  1428. buffer. Use @ and ! to get this hardware pointer, but C@@ to read the buffer."
  1429. ~UP
  1430. CREATE '
  1431. EDIT
  1432. | '
  1433.  
  1434. '
  1435. ( -> 32b ) The input stream is parsed, a number's value is placed on the
  1436. stack, a known module's execution address pointer is placed on the stack, an
  1437. unknown module generates an error."
  1438. ~UP
  1439. CREATE IMMEDIATE
  1440. EDIT
  1441. | IMMEDIATE
  1442.  
  1443. IMMEDIATE
  1444. ( -> ) Causes the local module to become immediate, it executes even if the
  1445. compiler is turned on."
  1446. ~UP
  1447. CREATE .CREATE
  1448. EDIT
  1449. | .CREATE
  1450.  
  1451. CREATE
  1452. ( -> ) The next module in the input stream has a dictionary entry and a code
  1453. segment created for it. In the code segment the name and code to push the
  1454. indirect address after the code (the new parameter area) is generated, followed
  1455. by a return. When the new module is executed, the parameter area indirect
  1456. address will be left on the data stack.
  1457.  
  1458. The module is created at the end of the local dictionary, unless the module is
  1459. the same as the name of the local dictionary. In that case, the module is
  1460. (re)created. None of the pointers are lost, but the code is reset as above. The
  1461. F$CRH bit is also set on a re-creation."
  1462. ~UP
  1463. CREATE ,
  1464. EDIT
  1465. | ,
  1466.  
  1467. ,
  1468. (32b -> ) The 32b value is placed at the end of the local dictionary."
  1469. ~UP
  1470. CREATE C,
  1471. EDIT
  1472. | C,
  1473.  
  1474. C,
  1475. (8b -> ) 8b value is compiled into the top-of-dictionary."
  1476. ~UP
  1477. CREATE ALLOT
  1478. EDIT
  1479. | ALLOT
  1480.  
  1481. ALLOT
  1482. (32b -> ) Top-of-dictionary pointer is advanced by 32b."
  1483. ~UP
  1484. CREATE :
  1485. EDIT
  1486. | :
  1487.  
  1488. :
  1489. ( -> ) CREATE is called to (re)create a header for the following module. The
  1490. compiler is turned on."
  1491. ~UP
  1492. CREATE ;
  1493. EDIT
  1494. | ;
  1495.  
  1496. ;
  1497. ( -> ) A return is compiled, then the compiler is turned off. Nesting of
  1498. control structures is also checked."
  1499. ~UP
  1500. CREATE (
  1501. EDIT
  1502. | (
  1503.  
  1504. (
  1505. ( -> ) All characters up to the closing ')' paren are ignored. This is the
  1506. comment module."
  1507. ~UP
  1508. CREATE \
  1509. EDIT
  1510. | \
  1511.  
  1512. \
  1513. ( -> ) Skip comments to the end of the line."
  1514. ~UP
  1515. CREATE GETSIZE
  1516. EDIT
  1517. | getsize
  1518.  
  1519. GETSIZE
  1520. (addr -> 32b1) Returns the size of the given module.
  1521. ~UP
  1522. EDIT
  1523. | compiling
  1524.  
  1525. COMPILATION
  1526. The Fifth compiler is unlike most compilers;  It
  1527. is made up of various bits and pieces that the
  1528. programmer invokes as needed.  Thus we can talk
  1529. about modules being immediate, (They execute at
  1530. COMPILE time!!) and modules generating code. The
  1531. following is a list of compiling modules in Fifth:
  1532.  
  1533.         [']             '               [
  1534.         ]               ;               :
  1535.         ,               (               \
  1536.         ABORT           ABORT"          C,
  1537.         COMP            [COMPILE]       CONSTANT
  1538.         CREATE          CHILD           EXECUTE
  1539.         FIND            >IN             LITERAL
  1540.         NEXT            STATE           TEXT
  1541.         TRACE           VARIABLE        WORD
  1542.         GETSIZE
  1543. ~UP
  1544. CREATE COMPARISON
  1545. CREATE XOR
  1546. EDIT
  1547. | XOR
  1548.  
  1549. XOR
  1550. (32b1 32b2 -> 32b3) Exclusive or 32b1 to 32b2 yielding 32b3."
  1551. ~UP
  1552. CREATE U<
  1553. EDIT
  1554. | U<
  1555.  
  1556. U<
  1557. (u32b1 u32b2 -> flag) Leave a true flag if unsigned integer u32b1 is less
  1558. than u32b2."
  1559. ~UP
  1560. CREATE F<
  1561. EDIT
  1562. | F<
  1563.  
  1564. F<
  1565. (32b1 32b2 -> flag ) Compares two floating point numbers."
  1566. ~UP
  1567. CREATE OR
  1568. EDIT
  1569. | OR
  1570.  
  1571. OR
  1572. (32b1 32b2 -> 32b3) Bitwise or 32b1 to 32b2 yielding 32b3."
  1573. ~UP
  1574. CREATE NOT
  1575. EDIT
  1576. | NOT
  1577.  
  1578. NOT
  1579. (32b1 -> 32b2) One's complement 32b1 yielding 32b2."
  1580. ~UP
  1581. CREATE AND
  1582. EDIT
  1583. | AND
  1584.  
  1585. AND
  1586. (32b1 32b2 -> 32b3) 32b1 is bit-wise anded with 32b2 yielding 32b3."
  1587. ~UP
  1588. CREATE >
  1589. EDIT
  1590. | >
  1591.  
  1592. >
  1593. (32b1 32b2 -> flag) A true flag is left if 32b1 is greater than 32b2,
  1594. otherwise a zero."
  1595. ~UP
  1596. CREATE =
  1597. EDIT
  1598. | =
  1599.  
  1600. =
  1601. (32b1 32b2 -> flag) A true flag is left if 32b1 equals 32b2, otherwise a
  1602. zero."
  1603. ~UP
  1604. CREATE <
  1605. EDIT
  1606. | <
  1607.  
  1608. <
  1609. (32b1 32b2 -> flag) A true flag is left if 32b1 is less than 32b2, otherwise
  1610. a zero."
  1611. ~UP
  1612. CREATE 0>
  1613. EDIT
  1614. | 0>
  1615.  
  1616. 0>
  1617. (32b -> flag) Replace 32b with a true flag (-1) if 32b is greater than zero,
  1618. otherwise replace 32b with a false flag (0)."
  1619. ~UP
  1620. CREATE 0=
  1621. EDIT
  1622. | 0=
  1623.  
  1624. 0=
  1625. (32b -> flag) Replace 32b with a true flag (-1) if 32b is equal to zero,
  1626. otherwise replace 32b with a false flag (0)."
  1627. ~UP
  1628. CREATE 0<
  1629. EDIT
  1630. | 0<
  1631.  
  1632. 0<
  1633. (32b -> flag) Replace 32b with a true flag (-1) if n is less than zero,
  1634. otherwise replace 32b with a false flag (0)."
  1635. ~UP
  1636. EDIT
  1637. | comparison
  1638.  
  1639. COMPARISON
  1640. These primitives manipulate boolean and logical values:
  1641.  
  1642.                 <               =               >
  1643.                 0<              0=              0>
  1644.                 AND             F<              NOT
  1645.                 OR              U<              XOR
  1646. ~UP
  1647. CREATE STACKOP
  1648. CREATE ?DUP
  1649. EDIT
  1650. | ?DUP
  1651.  
  1652. ?DUP
  1653. (32b -> 32b 32b) or (0 -> 0) If the top-of-stack value is zero, nothing
  1654. occurs, otherwise it is duplicated."
  1655. ~UP
  1656. CREATE SWAP
  1657. EDIT
  1658. | SWAP
  1659.  
  1660. SWAP
  1661. (32b1 32b2 -> 32b2 32b1) Top two stack elements are swapped."
  1662. ~UP
  1663. CREATE OVER
  1664. EDIT
  1665. | OVER
  1666.  
  1667. OVER
  1668. (32b1 32b2 -> 32b1 32b2 32b1) Stack is modified according to stack diagram."
  1669. ~UP
  1670. CREATE DEPTH
  1671. EDIT
  1672. | DEPTH
  1673.  
  1674. DEPTH
  1675. ( -> n) Return the depth of the stack, not counting n."
  1676. ~UP
  1677. CREATE PICK
  1678. EDIT
  1679. | PICK
  1680.  
  1681. PICK
  1682. (+n -> 32b) Leave a copy of the nth stack location over +n. +n is zero based
  1683. so DUP is the same as 0 PICK and OVER the same as 1 PICK."
  1684. ~UP
  1685. CREATE DUP
  1686. EDIT
  1687. | DUP
  1688.  
  1689. DUP
  1690. (32b -> 32b 32b) Duplicate the top-of-stack element."
  1691. ~UP
  1692. CREATE DROP
  1693. EDIT
  1694. | DROP
  1695.  
  1696. DROP
  1697. (32b -> ) A 32b is dropped from the stack."
  1698. ~UP
  1699. CREATE ?STACK
  1700. EDIT
  1701. | ?STACK
  1702.  
  1703. ?STACK
  1704. ( -> flag) Returns a true flag if the stack has underflowed."
  1705. ~UP
  1706. CREATE SSTACK
  1707. EDIT
  1708. | sstack
  1709.  
  1710. STACK (32b1 32b2 ... -> ... )
  1711.  
  1712. stack AB|ABAB           (32b1 32b2 -> 32b1 32b2 32b1 32b2)
  1713. stack ABC|CAB           (32b1 32b2 32b3 -> 32b3 32b1 32b2)
  1714. stack ABCDE|EE          (32b1 32b2 32b3 32b4 32b5 -> 32b5 32b5)
  1715.  
  1716. Let me explain the last example.  A is deepest, E is on on the top of the stack
  1717. on the `before' side of |. On the after side, E is the only thing left; ABCD
  1718. were all thrown away, and E is DUPed, giving two copies of E.
  1719.  
  1720. STACK can simplify understanding of complicated stack manipulations.
  1721.  
  1722. STACK is limited to no more than 26 elements on the before side, no limit on
  1723. the after side. It is not case sensitive, but the letters on the before side
  1724. must be in order "ABC..." .
  1725. ~UP
  1726. EDIT
  1727. | stackop
  1728.  
  1729. STACK_OP
  1730. These stack operators manipulate the data stack:
  1731.  
  1732.   DEPTH  ?DUP   OVER  ?STACK    SWAP
  1733.   DROP   DUP    PICK  STACK
  1734. ~UP
  1735. CREATE MISC
  1736. CREATE IN
  1737. EDIT
  1738. | IN
  1739.  
  1740. IN
  1741. (32b -> 8b) Input 8b from port number 32b."
  1742. ~UP
  1743. CREATE OUT
  1744. EDIT
  1745. | OUT
  1746.  
  1747. OUT
  1748. (8b 32b -> ) The 8b value is outputted thru port number 32b."
  1749. ~UP
  1750. CREATE .UP
  1751. EDIT
  1752. | .UP
  1753.  
  1754. UP
  1755. ( -> ) Raises the environment level, does nothing if at ROOT level."
  1756. ~UP
  1757. CREATE SAVE
  1758. EDIT
  1759. | SAVE
  1760.  
  1761. SAVE
  1762. ( -> ) Saves the current Fifth environment to a disk file under the ROOT
  1763. name, with a .EXE extension. To re-load the environment, type it's name to
  1764. MSDOS. If a .EXE file already exists when saving, it is renamed to .BAK ."
  1765. ~UP
  1766. CREATE R@
  1767. EDIT
  1768. | R@
  1769.  
  1770. R@
  1771. ( -> 32b) Copies a value from the return stack and places it on the data
  1772. stack."
  1773. ~UP
  1774. CREATE R>
  1775. EDIT
  1776. | R>
  1777.  
  1778. R>
  1779. ( -> 32b) Pulls a value from the return stack and places it on the data
  1780. stack."
  1781. ~UP
  1782. CREATE MEMORY
  1783. EDIT
  1784. | MEMORY
  1785.  
  1786. MEMORY
  1787. ( -> 32b) Returns the size of the largest HEAP block. Saving and reloading
  1788. Fifth will compress the HEAP."
  1789. ~UP
  1790. CREATE INT
  1791. EDIT
  1792. | INT
  1793.  
  1794. INT
  1795. (Registers Int -> Registers Flags) The registers are 8 16b values in this
  1796. order: ES DS SI DI DX CX BX AX . Stack them as 4 32b values. Push all registers
  1797. on the stack prior to using INT. The registers are loaded and the interrupt is
  1798. called. The registers are pushed back on the stack with the flags."
  1799. ~UP
  1800. CREATE .EDIT
  1801. EDIT
  1802. | .EDIT
  1803.  
  1804. EDIT
  1805. ( -> ) Edits the text of a single module. (Edits the local module.) Use DIR to
  1806. edit program structure. See the Text Editor section of the Fifth manual."
  1807. ~UP
  1808. CREATE .DIR
  1809. EDIT
  1810. | .DIR
  1811.  
  1812. DIR
  1813. ( -> ) Invokes the dictionary editor. This is the word that is used to edit
  1814. the structure of Fifth programs.  DIR is invoked by typing `DIR' in the
  1815. interactive environment.  Use the arrow keys to move around in your program.
  1816. See the full description in the Dictionary Editor section in the manual.
  1817.  
  1818. To load a file, use the 'L' key, type the filename (EX: TOWERS.FIV) and a
  1819. carrige return. During loading, a series of '>' symbols will appear. After
  1820. loading you will be in the interactive environment again. Typing DIR returns
  1821. you to the dictionary editor.
  1822. ~UP
  1823. CREATE DECIMAL
  1824. EDIT
  1825. | DECIMAL
  1826.  
  1827. DECIMAL
  1828. ( -> ) Force the radix to base 10."
  1829. ~UP
  1830. CREATE BYE
  1831. EDIT
  1832. | BYE
  1833.  
  1834. BYE
  1835. ( -> ) Exits to calling procedure. (MSDOS)"
  1836. ~UP
  1837. CREATE BASE
  1838. EDIT
  1839. | BASE
  1840.  
  1841. BASE
  1842. ( -> addr) Leaves the address of the radix. Valid radix are in the range 2
  1843. to 72."
  1844. ~UP
  1845. CREATE >R
  1846. EDIT
  1847. | >R
  1848.  
  1849. >R
  1850. (32b -> ) 32b value is pushed onto the return stack."
  1851. ~UP
  1852. CREATE :=
  1853. EDIT
  1854. | :=
  1855.  
  1856. :=
  1857. ( addr -> )
  1858. To use this word, you must load ASSIGN.FIV.
  1859.  
  1860. This word allows conventional expressions to be written in Fifth.  It expects
  1861. an address on the stack.  This is where the results of the expression will be
  1862. stored.  For example, a := ( 5.0 + 6.0 ) * ( b / ( d - e [ 3 ] ) ; will assign
  1863. to A the value of the given expression. Notice that spaces ARE required between
  1864. each operator, variable, etc.
  1865.  
  1866. Also notice the use of the array E. Its subscript, 3, is inclosed by square
  1867. brackets.  E must be defined as an array using DOES>. Each element in the array
  1868. must be four bytes long. A two dimensional array can be included by inclosing
  1869. each subscript in square brackets. ( For example, b := a [ 4 ] [ 6 ] ; )
  1870.  
  1871. Every statment must be ended with a semicolon.  Notice that mixed mode
  1872. arithmetic is NOT supported.  If you want the n+1 element of an array, you must
  1873. write something like:
  1874.    n @ 1+ tmp !
  1875.    b := e [ tmp ] + 8.0 ;
  1876. Single integer constants are allowed, but a := 3 + b ; is the same as
  1877.    3 b @ f+ a !
  1878. ~UP
  1879. CREATE ENVIRON
  1880. EDIT
  1881. | environ
  1882.  
  1883. ENVIRON
  1884. (addr -> ) Moves to the local environment of the given module.
  1885. ~UP
  1886. EDIT
  1887. | misc
  1888.  
  1889. MISC
  1890. This section describes primitives that do not lump into any one category.
  1891.  
  1892.                 >R              BASE            BYE
  1893.                 DECIMAL         DIR             EDIT
  1894.                 IN              INT             MEMORY
  1895.                 OUT             R@              R>
  1896.                 SAVE            UP              :=
  1897.                 ENVIRON
  1898. ~UP
  1899. EDIT
  1900. | build-help-file
  1901.  
  1902.         help ( -> )
  1903.  
  1904. The HELP module returns information on the modules in
  1905. the system.  The syntax for using HELP is:
  1906.  
  1907.         HELP <module-name>
  1908.  
  1909. Try HELP out on the Fifth primitives DIR and BYE.
  1910. In addition, you can request help with:
  1911.  
  1912.         ARITHMETIC      ASSEMBLER       COMPARISON      COMPILATION
  1913.         CONDITIONAL     GRAPHICS        I/O
  1914.         MISC            STACK_OP        STRUCTURES
  1915.  
  1916. Some of the language extensions require loading of a .FIV file. These files are
  1917. similiar to .H files in the "C" language. To load a .FIV file, check the help
  1918. on the DIR command, i.e. "HELP DIR".
  1919. ~UP
  1920. EDIT
  1921. \ Executing any entry will build a helpfile
  1922. \ Containing the executed entry and all entries beneath it.
  1923. \
  1924. \ (Normally, you will execute BUILD-HELP-FILE...)
  1925. \
  1926. create build
  1927. ~UP
  1928. ABORT